
{extend name="common@list" /}
{block name="jsset"}

{/block}
{block name="nav"}
	<span class="layui-breadcrumb">
		<a href="">教务管理</a>
		<a href="">班级管理</a>
		<a><cite>班级列表</cite></a>
	</span>
{/block}
{block name="search"}
	<div class="layui-form-item">
      <label for="searchval" class="layui-form-label">
          关键字
      </label>
      <div class="layui-input-block">
          <input type="text" id="searchval" name="searchval"
          autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
	    <label for="school" class="layui-form-label" style="height: 100%">学校</label>
	    <div class="layui-input-block" onclick ="clickSearchButton('#search','mytable')">
	    	{php}
	    		$schoollist = schlist('校级','校级');
	    	{/php}
	    	<input type="radio" name="school" value="" title="无">
	    	{volist name="schoollist" id="vo"}
	    		<input type="radio" name="school" title="{$vo.jiancheng}" value="{$vo.id}" lay-skin="primary">
	    	{/volist}
	    </div>
	</div>
    <div class="layui-form-item" style="margin-bottom: 0;">
	    <label for="ruxuenian" class="layui-form-label" style="height: 100%">年级</label>
	    <div class="layui-input-block" onclick ="clickSearchButton('#search','mytable')">
	    	<input type="radio" name="ruxuenian" value="" title="无">
	    	{foreach :nianjiList() as $key=>$vo }
	    		<input type="radio" name="ruxuenian" title="{$vo}" value="{$key}" lay-skin="primary">
	    	{/foreach}
	    </div>
	</div>
{/block}
{block name="table"}
	<table id="tabledemo" lay-filter="mytable" lay-size="sm"></table>
{/block}
{block name="myjs"}
	<!-- 表格上面按钮模板 -->
<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-danger" lay-event="dels">
			<i class="iconfont">&#xe69d;</i> 批量删除
		</button>
		<button class="layui-btn" lay-event="add">
			<i class="iconfont">&#xe6b9;</i> 添加
		</button>
	</div>
</script>
<!-- 记录操作按钮模板 -->
<script type="text/html" id="barDemo">
	<a class="layui-btn-xs" lay-event="befo" title="前移"><i class="layui-icon">&#xe603;</i></a>
	<a class="layui-btn-xs" lay-event="end" title="后移"><i class="layui-icon">&#xe602;</i></a>
	<a class="layui-btn-xs" lay-event="del" title="删除"><i class="layui-icon">&#xe640;</i></a>
</script>
<!-- 表格操作 -->
<script>
	// 设置列
	options.cols=[[ //表头
			{type:'checkbox', fixed: 'left'},
			{field: 'id', title: 'ID', minWidth:100,sort: true},
			{field: 'banjiTitle', title: '班级名称', minWidth:100},
			{field: 'school', title: '单位名称',sort: true, minWidth:240,templet:function(d){
				var str='';
				if(d.gl_school)
				{
					str = d.gl_school.title;
				}
				return str;
			}},
			{field: "ruxuenian",title: '入学年',sort: true},
			{field: 'paixu', title: '排序', sort: true},
			{field:"gl_student_count",title: '学生数',sort: true},
			{field: 'status', title: '状态',templet:'#status', sort: true},
			{field: 'id', title: '操作',toolbar: '#barDemo',minWidth:160}
		]];

	// 提交搜索条件后重载表格
    layui.use(['table','cjgl'],function(){
      var table = layui.table
      		cjgl = layui.cjgl;
      //表头工具栏事件
      table.on('toolbar(mytable)', function(obj){
      	switch(obj.event){
      		case 'dels':
      			var checkStatus = table.checkStatus('mytable'); //idmytable 即为基础参数 id 对应的值
      			cjgl.delAll(checkStatus,'/banji','mytable');
      			break;
      		case 'add':
      			cjgl.add('添加班级','/banji/create','600','300');
      			break;
      		};
      });

      //监听行工具条
      table.on('tool(mytable)', function(obj){
      	var data = obj.data; //获得当前行数据
      	var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
      	var tr = obj.tr; //获得当前行 tr 的DOM对象
      	switch(layEvent){
      		case 'detail':// 查看
	          layer.msg('查看' + data.id);
	          break;
	        case 'befo':// 前移
	          yidong(this,'/banji/'+data.id+'/yidong',-1);
	          break;
	        case 'end':// 后移
	          yidong(this,'/banji/'+data.id+'/yidong',1);
	          break;
	        case 'del':// 删除
	          cjgl.del(obj,"/banji");
	          break;
	        case 'edit':// 编辑
	          cjgl.add('编辑班级','/banji/'+obj.data.id+'/edit','600','300');
	          break;
	        case 'status':// 状态
	          cjgl.status(obj,"{:url('setstatus')}");
	          break;
      	};
      });
    });
</script>
{/block}